﻿<!DOCTYPE html>

@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<dynamic>


<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
    
    <script type="text/javascript">
        function ToggleSyncEnabled(obj, colId) {
            $.get('~/ToggleSyncEnabled', { id: colId, x: Math.random() }, function (result) {
                if (result.success) {
                    if (result.newValue) {
                        $(obj).text('True');
                    } else {
                        $(obj).text('False');
                    }
                }
                else {
                    alert(result.success);
                }
            });
            return false;
        }

        function ImportSchema(obj, id, type) {
            $.ajax({
                type: "POST",
                url: 'http://localhost:5010/ImportSchema',
                data: { id: id, type: type, x: Math.random() },
                success: function() {
                    alert("done");
                    $('importSchemaLink').text('Done');
                }
            });


            //$.post('~/ImportSchema', { id: id, type: type, x: Math.random() }, function (result) {
            //    if (result.success) {
            //        alert("done");
            //        $('importSchemaLink').text('Done');
            //    }
            //    else {
            //        alert(result.success);
            //    }
            //});
            return false;
        }
    </script>
</head>
<body>
    

    <div>
        <table class="box">
            <tr>
                <th>Namn</th>
                <th>Tabell</th>
                <th>Importerad</th>
                <th>Val</th>
            </tr>
            @{ bool even = true; }
            @foreach (var e in Model)
            {
                <tr @((even = !even) ? "class=even" : "")>
                    <td class="form">
                        <a href="/schemashow?id=@e.Id&type=@e.Type">:@e.Name</a>
                    </td>
                    <td class="form">
                        @e.SourceTableName
                    </td>
                    <td class="form">
                        @((e.ImportDat != null) ? e.ImportDat.ToString() : "")
                    </td>
                    <td class="form">
                        <a id="importSchemaLink" href="" onclick="return ImportSchema(this, @e.Id, @e.Type);">Importera</a>
                    </td>

                </tr>
            }
        </table>
    </div>

</body>
</html>